unit Password;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Mask, Menus;

type
  TFormPassword = class(TForm)
    Label3: TLabel;
    EditPassword: TMaskEdit;
    Label1: TLabel;
    EditConfirm: TMaskEdit;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    Label2: TLabel;
    procedure BtnCancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure EditPasswordKeyPress(Sender: TObject; var Key: Char);
    procedure EditConfirmKeyPress(Sender: TObject; var Key: Char);
    procedure BtnOKClick(Sender: TObject);
    procedure EditPasswordChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    password: string;
  end;

var
  FormPassword: TFormPassword;

implementation

{$R *.DFM}

procedure TFormPassword.FormCreate(Sender: TObject);
begin
  password:='';
end;

procedure TFormPassword.BtnCancelClick(Sender: TObject);
begin
  close;
end;

procedure TFormPassword.EditPasswordKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    EditConfirm.setfocus;
    key:=#0;
  end;
end;

procedure TFormPassword.EditConfirmKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    BtnOK.click;
    key:=#0;
  end;
end;

procedure TFormPassword.EditPasswordChange(Sender: TObject);
begin
  if (length(EditPassword.text) > 0) and (length(EditConfirm.text) > 0) then
    BtnOK.enabled:=true
  else BtnOK.enabled:=false;
end;

procedure TFormPassword.BtnOKClick(Sender: TObject);
begin
  password:=EditPassword.text;
  close;
end;

end.
